{
"cells": [
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [],
"source": [
"import numpy\n",
"import matplotlib.pyplot as plt\n",
"%matplotlib inline"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## Read simulation input from a file"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"It is often useful to read simulation inputs from a file. Let's do this for our standard tank system.\n",
"\n",
"
\n",
"\n",
"\\begin{align}\n",
"F_{out} &= kh\\\\\n",
"\\frac{\\mathrm{d}h}{\\mathrm{d}t} &= \\frac{1}{A}\\left(F_{in} - F_{out}\\right)\\\\\n",
"\\end{align}"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First we define the parameters of the system"
]
},
{
"cell_type": "code",
"execution_count": 2,
"metadata": {},
"outputs": [],
"source": [
"K = 1\n",
"A = 1"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"Then, we'll read the values of $F_{in}$ from an Excel file using `pandas.read_excel`."
]
},
{
"cell_type": "code",
"execution_count": 3,
"metadata": {},
"outputs": [],
"source": [
"import pandas"
]
},
{
"cell_type": "code",
"execution_count": 4,
"metadata": {},
"outputs": [
{
"data": {
"text/html": [
"
| \n", " | Time | \n", "Fin | \n", "
|---|---|---|
| 0 | \n", "0 | \n", "1.0 | \n", "
| 1 | \n", "5 | \n", "2.0 | \n", "
| 2 | \n", "10 | \n", "2.0 | \n", "
| 3 | \n", "15 | \n", "1.5 | \n", "
| 4 | \n", "20 | \n", "1.0 | \n", "
| 5 | \n", "25 | \n", "2.0 | \n", "
| 6 | \n", "30 | \n", "2.0 | \n", "